#ifndef TRANSFORMERCONTENTPORTRECORD_HPP_3
#define TRANSFORMERCONTENTPORTRECORD_HPP_3

#include "logger.hpp"
#include "transContentDefine.h"
#include "transContentErrorCode.h"
#include "transContentDispatcher.hpp"
#include "transContentMemory.hpp"


class TransContentPortRecord{
private:
	int localPort;
	TransContentRecordMemoryIn* InMemory;
	TransContentRecordMemoryOut* OutMemory;
public:

	///
	/// constructor
	///
	TransContentPortRecord(){
		debug_enter();
		InMemory = new TransContentRecordMemoryIn();
		OutMemory = new TransContentRecordMemoryOut();
		debug_leave();
	}

	///
	/// destructor
	///
	~TransContentPortRecord(){
		debug_enter();
		if(InMemory != NULL){
			delete InMemory;
			InMemory = NULL;
		}
		if(OutMemory != NULL){
			delete OutMemory;
			OutMemory = NULL;
		}
		debug_leave();
	}
	
	///
	/// send data to target
	///
	int sendTo(const EndPoint* target, int flag, const void* buffer, int bufferLen, int timeout, sendToSyncCallback stscb){
		logd_info("port record sendTo, passed info to out Memory");
		return OutMemory->sendTo(target, flag, buffer, bufferLen, timeout, stscb);
	}

	///
	/// recevie from
	///
	int receiveFrom(int flag, void* buffer, int bufferLen, int timeout, receiveFromSyncCallback rfscb){
		logd_info("port record receiveFrom, passed info to In Memory");
		return InMemory->receiveFrom(flag, buffer, bufferLen, timeout, rfscb);
	}
	
	///
	/// get in data
	///
	int getData(char* buffer, int len){
		logd_info("port record getData, passed to In Memroy");
		return InMemory->getData(buffer, len);
	}
	
	///
	/// response packet data
	///
	int response(char* buffer, int index);
};
#endif //TRANSFORMERCONTENTPORTRECORD_HPP_3
